#pragma ident "$Id: SolutionStoreForPCE.hpp$"

/**
 * @file SolutionStoreForPCE.hpp
 * Store solution of kalman filter.
 */

#ifndef SOLUTION_STORE_FOR_PCE_HPP
#define SOLUTION_STORE_FOR_PCE_HPP

#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include "DataStructures.hpp"

namespace gpstk
{

    /** @addtogroup DataStructures */

    class SolutionStoreForPCE
    {
    public:

        /// Constructor
        SolutionStoreForPCE() {};


        /** Prepare state vector, covariance matrix and index.
         *
         * @return this object.
         */
        virtual SolutionStoreForPCE& Prepare(const sourceRinex& gData);


        // Get previous time.
        virtual CommonTime getPreviousTime() const
        { return prevTime; }


        // Get current time.
        virtual CommonTime getCurrentTime() const
        { return currTime; }


        // Set current epoch.
        virtual SolutionStoreForPCE& setCurrentTime( const CommonTime& time )
        {
            if( currTime != time )
            {
                prevTime = currTime;
                currTime = time;
            }

            return *this;
        }


        // Get SourceID set.
        virtual SourceIDSet getSourceIDSet(void) const
        { return sourceSet; }


        // Get SatID set.
        virtual SatIDSet getSatIDSet(void) const
        { return satSet; }


        // Get number unknown.
        virtual int getNumUnknown(void) const
        { return numUnknown; }


        // Get state vector.
        virtual Vector<double> getStateVector(void) const
        { return state; }


        // Set state vector.
        virtual SolutionStoreForPCE& setStateVector(const Vector<double>& vec)
        { state = vec; return (*this); }


        // Get covariance matrix.
        virtual Matrix<double> getCovarMatrix(void) const
        { return covar; }


        // Set covariance matrix.
        virtual SolutionStoreForPCE& setCovarMatrix(const Matrix<double>& mat)
        { covar = mat; return (*this); }


        // Get sat clock.
        virtual satValueMap getSatClock(void) const
        { return satClock; }


        // Set sat clock.
        virtual SolutionStoreForPCE& setSatClock(const satValueMap& clock)
        { satClock = clock; return (*this); }


        // Get source index.
        virtual std::map<SourceID,int> getSourceIndex(void) const
        { return sourceIndex; };


        // Set source index.
        virtual SolutionStoreForPCE& setSourceIndex(const SourceIntMap& index)
        { sourceIndex = index; return (*this); };


        // Get sat index.
        virtual std::map<SatID,int> getSatIndex(void) const
        { return satIndex; };


        // Set sat index.
        virtual SolutionStoreForPCE& setSatIndex(const SatIntMap& index)
        { satIndex = index; return (*this); };


        // Get ambi index.
        virtual SourceSatIntMap getAmbiIndex(void) const
        { return ambiIndex; };


        // Set ambi index.
        virtual SolutionStoreForPCE& setAmbiIndex(const SourceSatIntMap& index)
        { ambiIndex = index; return (*this); };


        /// Destructor
        virtual ~SolutionStoreForPCE() {};


    private:

        /// previous time
        CommonTime prevTime;

        /// current time
        CommonTime currTime;

        SourceIDSet sourceSet;
        SatIDSet satSet;

        int numUnknown;

        Vector<double> state;
        Matrix<double> covar;

        satValueMap satClock;

        SourceIntMap sourceIndex;
        SatIntMap satIndex;
        SourceSatIntMap ambiIndex;

    }; // End of class 'SolutionStoreForPCE'

}  // End of namespace gpstk

#endif   // SOLUTION_STORE_FOR_PCE_HPP
